package com.spreadk.demo.mapper.impl;

import com.spreadk.demo.entity.User;
import com.spreadk.demo.mapper.UserMapper;
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author:Gan Linghao
 * @date:2020/12/8
 * @time:20:29
 * @description:no description
 */
public class UserMapperImpl2 extends SqlSessionDaoSupport implements UserMapper {

    @Override
    public List<User> getUser(String ids) {
        System.out.println("---------------进入USER查询getUser----------------");
        SqlSession sqlSession = getSqlSession();
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
//        int i = 1 / 0;
        return mapper.getUser(ids);
    }

    //(transactionManager = "dataSourceTransactionManager")
    @Transactional
    @Override
    public int updateUser(String name, Long id) {
        SqlSession sqlSession = getSqlSession();
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        int row =  mapper.updateUser(name,id);
                int i = 1 / 0;
        System.out.println("1111111111111111111-----");
        return row;
    }
}
